#! /bin/bash
if [ $# -eq 0 ];then
	echo "usage: `basename $0` file"
	exit 1
fi

if [ ! -f $1 ];then
	echo "error file"
	exit 2
fi

IFS='
'
for line in `cat $1`
do
	if [ ${#line} -eq 0 ];then
		continue
	fi
	user=`echo "$line" | awk '{print $1}'`
	pass=`echo "$line" | awk '{print $2}'`
	id $user &>/dev/null
	if [ $? -eq 0 ];then
		echo "user $user 已存在"
	else
		useradd $user
		echo "$pass" |passwd --stdin $user &>/dev/null
		if [ $? -eq 0 ];then
			echo "$user is create..."
		fi
	fi
done
